﻿using Collections.Pooled;
using furion.blog.Domain.Shared.Attribute;
using furion.blog.Domain.Shared.Vo;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace furion.blog.Domain.Shared.Enum
{
    public enum TagsGroupEnum
    {
        /// <summary>
        /// 房源
        /// </summary>
        //[EnumAttribute(Name = "房源",Desc = "房源",Value = "House")]
        //House,
        /// <summary>
        /// 招聘
        /// </summary>
        //[EnumAttribute(Name = "招聘",Desc = "房源",Value = "Job")]
        //Job,
        /// <summary>
        /// 家政
        /// </summary>
        //[EnumAttribute(Name = "家政", Desc = "家政", Value = "HouseKeepingSkill")]
        //HouseKeepingSkill,

        /// <summary>
        /// 平台
        /// </summary>
        [EnumAttribute(Name = "平台", Desc = "平台自身", Value = "System")]
        HouseKeepingSkill,

    }


    public class TagsGroup {
        public static async Task<PooledSet<NameValueVO>> Items() {
            return await Task.Run(() => {
                PooledSet<NameValueVO> ret = new PooledSet<NameValueVO>();
                Type t = typeof(TagsGroupEnum);
                FieldInfo fd = null;
                foreach (var name in t.GetEnumNames())
                {
                    fd = t.GetField(name);
                    var attr = fd.GetCustomAttribute(typeof(EnumAttribute), false) as EnumAttribute;
                    ret.Add(new NameValueVO { Name = attr.Name, Value = attr.Value });
                }
                return ret;
            });
        }
    }


}
